package com.mc.cloud.mall.cartOrder.controller;

import com.github.pagehelper.PageInfo;
import com.mc.cloud.mall.cartOrder.service.OrderService;
import com.mc.cloud.mall.common.common.MallRestResponse;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName AdminOrderController
 * @Author MC
 * @Date 2020/11/10 13:49
 * @Version 1.0
 **/
@RestController
public class AdminOrderController {
    
    @Autowired
    OrderService orderService;
    
    @GetMapping("/admin/order/list")
    @ApiOperation("后台：订单列表")
    public MallRestResponse list(@RequestParam Integer pageNum, @RequestParam Integer pageSize){
        PageInfo pageInfo = orderService.orderListForAdmin(pageNum, pageSize);
        
        return MallRestResponse.success(pageInfo);
    }
    
    /**
     * 后台：发货
     * @param orderNo
     * @return
     */
    @PostMapping("/admin/order/delivered")
    @ApiOperation("后台：发货")
    public MallRestResponse delivered(@RequestParam String orderNo){
        orderService.delivered(orderNo);
        return MallRestResponse.success();
    }
    
    /**
     * 完结订单 : 管理员和用户都可以调用
     * @param orderNo
     * @return
     */
    @PostMapping("/order/finish")
    @ApiOperation("完结订单：管理员和用户都可以调用")
    public MallRestResponse finish(@RequestParam String orderNo){
        orderService.finish(orderNo);
        return MallRestResponse.success();
    }
}
